package commands;

import nanoxml.XMLElement;
import utils.ITransmittable;

/**
 * This command represents a notification that a client choose to exit 
 */
public class CommandUserExit implements ITransmittable
{
	private final static String ATTR_USER_NAME = "Username";
	
	private String username = null; 
	
	public CommandUserExit (String username)
	{
		this.username = username;
	}
	
	public CommandUserExit(XMLElement command)
	{
		this((String)command.getAttribute(ATTR_USER_NAME));
	}

	@Override
	public XMLElement toXML()
	{
		XMLElement message = new XMLElement();
		message.setName(Commands.USER_EXIT);
		message.setAttribute(ATTR_USER_NAME, username);
		
		return message;
	}
	
	public String getUsername()
	{
		return username;
	}
}
